package com.app114.app.android.rk;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.View;

import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.app114.app.android.rk.utils.DeviceUtil;

public class LoadActivity extends BaseFragmentActivity {

	private Handler mHandler;
	private AnimaRunnable animaRunnable;
	private View mRoot;

	// private View mText ;

	private class AnimaRunnable implements Runnable {

		@Override
		public void run() {
			Intent intent = new Intent(LoadActivity.this, Main.class);
			startActivity(intent);
			finish();
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		// if (!ConnectionNet.isConnected(this, false)) {
		// showSettingDialog(this);
		// mHandler.removeMessages(Conf.SPLASH_DISPLAY_LENGHT);
		// mHandler.removeCallbacks(animaRunnable);
		// } else {
		mHandler.postDelayed(animaRunnable, 3000);
		// }
	}

	@Override
	public boolean dispatchKeyEvent(KeyEvent event) {
		if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
			if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
				mHandler.removeCallbacks(animaRunnable);
				finish();
				return true;
			}
		}

		return super.dispatchKeyEvent(event);
	}

	@Override
	protected void activitySetup(Bundle savedInstanceState) {
		setContentView(R.layout.layout_load);
		// mWebView.setWebViewClient(new ExtendedWebViewClient(this));
		mRoot = findViewById(R.id.root);
		// mText = findViewById(R.id.load_text) ;
		DeviceUtil.animation(this, R.anim.slide_up_in, mRoot);
		// DeviceUtil.animation(this, R.anim.push_left_in, mText) ;
		mHandler = new Handler();
		animaRunnable = new AnimaRunnable();
	}

	@Override
	protected boolean _onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	protected boolean _onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	protected void activityDestory() {
		if (mHandler != null) {
			mHandler = null;
		}
	}
}